const template = `
	<div>
		<van-nav-bar
		  :title="title"
		  left-arrow
			left-text="返回首页"
			@click-left="onBack"
		/>
		<div class="main__inner">
			<div class="main__base-info">
				<div class="login-wrapper">
					<div class="login-userinfo">
						<van-icon name="manager" />
						<span class="login-username">{{ nickName }}</span>
					</div>
				</div>
				<div class="weather-wrapper">
					<img :src="'./assets/plugins/vant/theme/default/weather/cake/' + weatherImg + '.png'" />
					<span>{{ weatherStr }}</span>
				</div>
			</div>
			<div class="main__business-nav">
				<div class="main-all-modules">
					<img style="width: 20px;" src="./assets/plugins/vant/theme/default/main/全部应用.png" />
					<span style="margin-left: 6px;font-weight: 500;">全部应用</span>
				</div>
				<ul>
					<li v-for="(item, index) in businessList" :key="index" class="business-item">
						<div class="business-item__inner">
							<a @click="$router.push(item.path)" class="business-item__link">
								<img class="business-item__img" :src="'./assets/plugins/vant/theme/default/main/' + item.title + '.png'" />
							</a>
							<span class="business-item__title">{{ item.title }}</span>
						</div>
					</li>
				</ul>
			</div>
		</div>
	</div>
`;

export default {
	
	created() {
		this.getWeather();
	},
	data() {
		return {
			title: '智慧生产',
			businessList: [
				{
					path: '/main/scan',
					title: '扫一扫',
				},
				{
					path: 'main/patrolDetail/deviceId123',
					title: '巡检明细',
				},
				{
					path: 'main/patrol',
					title: '立即巡检',
				},
				{
					path: '/main/todayPatrol',
					title: '当日巡检',
				},
				{
					path: '/main/historyPatrol',
					title: '历史巡检',
				},
				/* {
					path: '/main/error',
					title: '异常反馈',
				},
				{
					path: '/main/report',
					title: '移动报表',
				},
				{
					path: '/main/scan',
					title: '扫一扫',
				},
				{
					path: '/main/error',
					title: '异常记录',
				}, */
				{
					path: '/main/gy',
					title: '在线数据',
				},
			],
			// 天气api
			weatherAppId: '11946696',
			weatherAppSecret: '0COAB1Bz',
			weatherImg: '',
			weatherStr: '',
		}
	},
	computed: {
		nickName() {
			return this.$root.nickName;
		}
	},
	methods: {
		getWeather() {
			axios.get(`https://www.tianqiapi.com/free/day?appid=${this.weatherAppId}&appsecret=${this.weatherAppSecret}&city=马鞍山`)
			.then(resp => {
				let data = resp.data;
				this.weatherImg = data.wea_img;
				this.weatherStr = `${data.tem_night} ~ ${data.tem_day} ℃, ${data.wea}`;
			});
		},
		onBack() {
			switch(this.$root.mode) {
				case 'prod': // 生产环境
					// 调用华衍接口，返回它们的APP主系统，仅在华衍APP上使用有效；
					HuayanH5.App.goBack();
					break;
				case 'dev': // 开发环境
					this.$toast('返回APP首页');
					break;
				case 'test': // 测试环境
					// to do
					break;
			}
			
			
		}
	},
	
	template,
	
	components: {
		
	}
}